import { createApp } from 'vue'
import App from './App.vue'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'

import '@/assets/css/style.scss'

import store from './store'
import router from './router'

import components from './components'

const app = createApp(App)

//全局注册组件
for(let key in components) {
    app.component('X' + key, components[key])
}

import * as globalProperties from './globalProperties'
import axios from 'axios'
Object.keys(globalProperties).forEach(key => {
    app.config.globalProperties[key] = globalProperties[key]
})

axios.interceptors.request.use(function (config) {
    config.headers.authorization = store.state.accessToken
    return config;
});

app.use(store)
app.use(router)

app.use(ElementPlus, {
    locale: zhCn,
})

app.mount('#app')
